<?php

namespace App\Models\Kms\App;

use App\Models\BaseModel;
use App\Models\Traits\KfSoftDeletes;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOne;

class ClientsModel extends BaseModel
{
    use KfSoftDeletes;

    protected $table = "kms_clients";

    const STATUS_NORMAL    = 1;
    const STATUS_FORBIDDEN = 0;
    const STATUS_TEXT      = [
        self::STATUS_NORMAL    => "正常",
        self::STATUS_FORBIDDEN => "禁用"
    ];

    const TYPE_APP  = 0;
    const TYPE_SELF = 1;

    const AUTH_TYPE_ALL  = 1;
    const AUTH_TYPE_PART = 2;

    const AUTH_TYPE_TEXT = [
        self::AUTH_TYPE_ALL  => "全部可见",
        self::AUTH_TYPE_PART => "部分可见"
    ];

    const CHILD_TYPE_1    = 1;
    const CHILD_TYPE_2    = 2;
    const CHILD_TYPE_3    = 3;
    const CHILD_TYPE_4    = 4;
    const CHILD_TYPE_TEXT = [
        self::CHILD_TYPE_1 => "相机",
        self::CHILD_TYPE_2 => "相册",
        self::CHILD_TYPE_3 => "轨迹",
        self::CHILD_TYPE_4 => "打卡",
    ];


    /**
     * @return HasOne
     */
    public function clientsVersionRel(): HasOne
    {
        return $this->hasOne(ClientsVersionModel::class, "id", "versionId");
    }

    /**
     * @return HasMany
     */
    public function clientsAuthFsUser(): HasMany
    {
        return $this->hasMany(ClientsAuthModel::class, "clientId", "id");
    }

    /**
     * @return HasMany
     */
    public function clientsAuthFsDepartment(): HasMany
    {
        return $this->hasMany(ClientsAuthModel::class, "clientId", "id");
    }
}
